package dp

// https://leetcode-cn.com/problems/n-th-tribonacci-number/
// 泰波那契数
// 算法: 动态规划
// f(n+3) = f(n) + f(n - 1) + f(n - 2)
func Tribonacci(n int) int {
	if 0 == n {
		return 0
	}
	arr := make([]int, 100)
	arr[0], arr[1], arr[2] = 0, 1, 1
	for i := 3; i <= n; i++ {
		arr[i] = arr[i-1] + arr[i-2] + arr[i-3]
	}
	return arr[n]
}
